package com.hwqsdk.myapplication.practise;

import android.app.Application;

import com.hwqsdk.myapplication.data.DaoMaster;
import com.hwqsdk.myapplication.data.DaoSession;
import com.hwqsdk.myapplication.data.UserDao;

/**
 * Create by Fanketly on 2021/11/24
 * Gitee:https://gitee.com/fanketly
 */
public class App extends Application {
    public static UserDao userDao;

    @Override
    public void onCreate() {
        super.onCreate();
        userDao = createSession("user").getUserDao();
    }

    private DaoSession createSession(String name) {
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(this, name);
        return new DaoMaster(devOpenHelper.getWritableDatabase()).newSession();
    }
}
